package dangs.vo;

import dang.util.CommonConstants;

public class PagingVO {
	private int totalContent;
	private int nowPage;
	private int numberOfContentsPerPage = CommonConstants.CONTENT_NUMBER_PER_PAGE;
	private int numberOfPageGroup = CommonConstants.PAGEGROUP_NUMBER_PER_PAGE;
	
	public PagingVO(int totalContent, int nowPage){
		this.totalContent = totalContent;
		this.nowPage = nowPage;
	}
	
	public int getNowPage() {
		return nowPage;
	}
	
	public void setNowPage(int nowPage) {
		this.nowPage = nowPage;
	}
	
	public int getTotalPage() {
		int totalPage = totalContent/numberOfContentsPerPage;
		if(totalContent%numberOfContentsPerPage != 0){
			totalPage = totalPage + 1;
		}
		return totalPage;
	}
	
	public int getTotalPageGroup() {
		int totalPageGoup = getTotalPage()/numberOfPageGroup;
		if(getTotalPage()%numberOfPageGroup != 0){
			totalPageGoup = totalPageGoup+1;
		}
		return totalPageGoup;
	}
	
	public int getNowPageGroup(){
		int pageGroup = nowPage/numberOfPageGroup;
		if(nowPage%numberOfPageGroup != 0){
			pageGroup = pageGroup+1;
		}
		return pageGroup;
	}
	
	public int getStartPageOfPageGroup(){
		int startPageNo = (getNowPageGroup()-1)*numberOfPageGroup +1;
		return startPageNo;
	}
	
	public int getEndPageOfPageGroup() {
		int endPageNo = (getNowPageGroup() * numberOfPageGroup);
		if(endPageNo > getTotalPage()){
			endPageNo = getTotalPage();
		}
		return endPageNo;
	}
	
	public boolean isPreviousPageGroup(){
		boolean flag = false;
		if(getNowPageGroup()>1){
			flag = true;
		}
		return flag;
	}
	
	public boolean isNextPageGroup(){
		boolean flag = false;
		if(getNowPageGroup() < getTotalPageGroup()){
			flag=true;
		}
		return flag;
	}
}
